package lyl.images;

import java.awt.color.ICC_ColorSpace;
import java.awt.color.ICC_Profile;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

/**
 * @author Liu Yulong
 */
public class TestImage {

    public static void main(String[] args) throws IOException {
        File im_filenew = new File("d:\\《条例》宣贯系列海报1.JPG"); // 请用绝对路径
        BufferedImage image = null;
        try {
            image = ImageIO.read(im_filenew);
        }
        catch(IllegalArgumentException e){
            System.out.println("-------------------------");
            e.printStackTrace();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        int i = image.getHeight();
    }

    public static void fixImageICC() {
        File im_filenew = new File("d:\\《条例》宣贯系列海报1.JPG"); // 请用绝对路径
        BufferedImage image = null;
        try {
            image = ImageIO.read(im_filenew);
        }
        catch (Exception e) {
            ICC_Profile ICC_pf;
            try {
                ICC_pf = ICC_Profile.getInstance("D:/CMYK.pf");
                ICC_ColorSpace ICC_ClSpace = new ICC_ColorSpace(ICC_pf);
                // TODO 读图片但不知道怎么做
                // .....
            }
            catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    }
}
